package servlet;

import java.io.IOException;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Bizlogic.CAManager;
import DAO.MySQL.OrderDAOImpl;
import Model.Employee;
import Model.Order;

/**
 * @author TONY
 * 
 */
public class SaveOrder extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
	
		int Orderid=Integer.parseInt(request.getParameter("orderid"));
		int Customerid=Integer.parseInt(request.getParameter("customerid"));	
		HttpSession session=request.getSession();
		Employee employee=(Employee)session.getAttribute("employee");
		Date date=Calendar.getInstance().getTime();				
		Order order=new Order();
		order.setCustomerid(Customerid);
		order.setEmployeename(employee.getEmplyeename());
		order.setOrdernum(Orderid);
		order.setOrderdate(date);
		CAManager ca= new CAManager();
		//OrderDAOImpl odi=new OrderDAOImpl();
	    ca.insertNewOrder(order);
		request.getRequestDispatcher("home.jsp").forward(request, response);

		
		
		

	}

}
